#!/bin/bash

#Determine paths
SCRIPT_PATH=`dirname "$0"`
SCRIPT_PATH=`cd $SCRIPT_PATH; pwd`
LIB_PATH=`cd $SCRIPT_PATH/../lib; pwd`
EXAMPLES_PATH=`cd $SCRIPT_PATH/../examples; pwd`

# Main program

#Loop over all programs in the examples dir and run 'm
for example in `ls $EXAMPLES_PATH | grep pico`; do
	echo "-------- Running: $example --------------"
	
	#Compile the program
	STACKPROGRAM=`$SCRIPT_PATH/compiler $EXAMPLES_PATH/$example`
	echo "Compiled:\n $STACKPROGRAM \n"
	
	#Run it
	STACK=`echo "$STACKPROGRAM" | $SCRIPT_PATH/interpreter`
	echo "Stack after interpretation:\n $STACK \n"
	
	echo "-------- Done: $example --------------"
done